// Copyright (C) 2009, Jackie Ng
// http://code.google.com/p/mgfdo, jumpinjackie@gmail.com
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
// 
//
// See license.txt for more/additional licensing information

#ifndef MGSELECTCOMMAND_H
#define MGSELECTCOMMAND_H

#include "MgProvider.h"
#include "MgConnection.h"
#include "FdoCommonFeatureCommand.h"

class MgSelect : public FdoCommonFeatureCommand<FdoISelect, MgConnection>
{
	typedef FdoCommonFeatureCommand<FdoISelect, MgConnection> Parent;

public:
	MgSelect(MgConnection* conn) : Parent(conn) { }

protected:
	virtual ~MgSelect() { }

private:
	FdoPtr<FdoIdentifierCollection> mPropertiesToSelect;

public:
	/// <summary>Gets the FdoIdentifierCollection that holds the list of property names to 
    /// return with the result. If empty all properties of the specified class
    /// are returned.</summary>
    /// <returns>Returns the list of property names.</returns> 
    MG_API virtual FdoIdentifierCollection* GetPropertyNames ();

	/// <summary>Gets the FdoIdentifierCollection that holds the list of order by property names. If empty no ordering is used. This list is initially
    /// empty and the caller need to add the property that the command should use as a order by criteria.</summary>
    /// <returns>Returns the list of group by property names.</returns> 
    MG_API virtual FdoIdentifierCollection* GetOrdering(){ return NULL; }

    /// <summary>Set the ordering option of the selection. This is only used if the ordering collection is not empty.</summary>
    /// <param name="option">Is the ordering option and should be set to one of FdoOrderingOption_Ascending or FdoOrderingOption_Descending.
    /// FdoOrderingOption_Ascending is the default value.</param> 
    /// <returns>Returns nothing</returns> 
    MG_API virtual void SetOrderingOption( FdoOrderingOption  option ) {}

    /// <summary>Gets the ordering option.</summary>
    /// <returns>Returns the ordering option.</returns> 
    MG_API virtual FdoOrderingOption GetOrderingOption( ) { return (FdoOrderingOption)0; }

    /// \brief
    /// Gets the FdoLockType value (see "Locking Commands").
    /// 
    /// \return
    /// Returns the lock type.
    /// 
	MG_API virtual FdoLockType GetLockType();

    /// \brief
    /// Sets the FdoLockType value (see "Locking Commands").
    /// 
    /// \param value 
    /// Input the lock type.
    /// 
    /// \return
    /// Returns nothing
    /// 
	MG_API virtual void SetLockType(FdoLockType value);

    /// \brief
    /// Gets the FdoLockStrategy value (see "Locking Commands").
    /// 
    /// \return
    /// Returns the lock strategy.
    /// 
	MG_API virtual FdoLockStrategy GetLockStrategy();

    /// \brief
    /// Sets the FdoLockStrategy value (see "Locking Commands").
    /// 
    /// \param value 
    /// Input the lock strategy.
    /// 
    /// \return
    /// Returns nothing
    /// 
    MG_API virtual void SetLockStrategy(FdoLockStrategy value);

    /// \brief
    /// Executes the select command and returns a reference to an FdoIFeatureReader.
    /// 
    /// \return
    /// Returns the feature reader.
    /// 
    MG_API virtual FdoIFeatureReader* Execute();

    /// \brief
    /// Executes the select command and returns a reference to an
    /// IFeatureReader.
    /// 
    /// \return
    /// Returns the feature reader.
    /// 
    MG_API virtual FdoIFeatureReader* ExecuteWithLock();

    /// \brief
    ///  When executing the operation ExecuteWithLock lock 
    /// conflicts may occur. Those lock conflicts are reported. The 
    /// function GetLockConflicts returns a lock conflict reader 
    /// providing access to the list of lock conflicts that occurred 
    /// during the execution of the operation.
    /// 
    /// \return
    /// Returns a lock conflict reader.
    /// 
    MG_API virtual FdoILockConflictReader* GetLockConflicts();
};

#endif